import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
const { BASE_URL, PROD } = import.meta.env
/* 路由懒加载 */
const Login = () => import('../views/Login/index.vue') //登录界面
const Home = () => import('../views/Home/index.vue') //登录界面
const Error = () => import('../views/Error/index.vue') //404界面
const router = createRouter({
  history: PROD ? createWebHistory(BASE_URL) : createWebHashHistory(BASE_URL),
  routes: [
    {
      path: '/',
      component: Home,
    },
    {
      path: '/login',
      component: Login,
    },
    //404界面
    {
      name: '404页面面',
      path: '/:catchAll(.*)',
      component: Error,
      meta: { hideHeaderNav: true, hideHeaderTop: true },
    },
  ],
  // 路由滚动行为定制
  scrollBehavior() {
    return {
      top: 0,
    }
  },
})

export default router
